package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.KDBookingPaper;

/**
 * 
 * @author 
 *
 */
@DAO
public interface KDBookingPaperDAO{
	
	@SQL("SELECT * FROM KDBookingPaper WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.area!=null){ and area =:t.area } "
			+ "#if(:t.street!=null){ and street =:t.street } "
			+ "#if(:t.address!=''){ and address like '%##(:t.address)%' } "
			+ "ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<KDBookingPaper> query(@SQLParam("t") KDBookingPaper kDBookingPaper);
	
	@SQL("SELECT count(*) FROM KDBookingPaper WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.area!=null){ and area =:t.area } "
			+ "#if(:t.street!=null){ and street =:t.street } "
			+ "#if(:t.address!=''){ and address like '%##(:t.address)%' } "
			+ "ORDER BY updateAt DESC ")
    int querySzie(@SQLParam("t") KDBookingPaper kDBookingPaper);
    
    @SQL("select * from KDBookingPaper where id=:1")
    KDBookingPaper queryById(int id);
    
//    @SQL("INSERT INTO KDBookingPaper (type,beginAt,subPeriod,subNum,link,phone,invoiceTitle,city,area,street,address,prize,status,deleteFlag,createUser,createAT,updateUser,updateAT,memo) VALUES (:t.type,:t.beginAt,:t.subPeriod,:t.subNum,:t.link,:t.phone,:t.invoiceTitle,:t.city,:t.area,:t.street,:t.address,:t.prize,:t.status,:t.deleteFlag,:t.createUser,now(),:t.updateUser,now(),:t.memo)")
//    void create(@SQLParam("t") KDBookingPaper kDBookingPaper);
	
//	@SQL("UPDATE KDBookingPaper SET type=:t.type,beginAt=:t.beginAt,subPeriod=:t.subPeriod,subNum=:t.subNum,link=:t.link,phone=:t.phone,invoiceTitle=:t.invoiceTitle,city=:t.city,area=:t.area,street=:t.street,address=:t.address,prize=:t.prize,status=:t.status,updateUser=:t.updateUser,updateAT=now(),memo=:t.memo WHERE id=:t.id")
//    void update(@SQLParam("t") KDBookingPaper kDBookingPaper);
    
    @SQL("UPDATE KDBookingPaper SET memo=:2 WHERE id=:1")
    void updateMemoById(int id,String memo);
    
    @SQL("UPDATE KDBookingPaper SET status=1 WHERE id=:1")
    void updateStatusById(int id);
    
    @SQL("UPDATE KDBookingPaper SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    //导出数据
    @SQL("select id,type,beginAt,subPeriod,subNum,link,phone,tel,descs,invoiceTitle,city,area,street,address,prize,status,memo,deleteFlag,createAT,updateAT from KDBookingPaper where deleteFlag=1 #if(:start!=''){ and createAT>=:start } #if(:end!=''){ and createAT<=:end } order by id")
    List<Map> output(@SQLParam("start")String start, @SQLParam("end")String end);
}